#!/bin/bash

count=0
while [ "$count" -lt 100 ]
do
r=$(dig +short myip.opendns.com @resolver1.opendns.com)
if [ -n "$r" ]; then
   break
fi
count=$((count + 1))
done

if [ -z "$r" ]; then
  python send_mail.py ARGS
  exit 0
fi

subject="From pi4: (my public ip is: $r)"

python send_mail.py ARGS
exit 0
